import { View, Text, TextInput, Button, Image } from 'react-native'
import { Link,useRouter } from "expo-router";

import React from 'react'
import { Input } from '@rneui/themed';
import axios from 'axios'
export default function index() {
  let [user, setUser] = React.useState('')
  let [pwd, setPwd] = React.useState('')
  let login = async () => {
    let { data: { code } } = await axios.post('http://localhost:3000/show', { 'user': user, 'pwd': pwd })
    console.log(code);
  }
  let nav=useRouter()

  return (
    <View style={{ backgroundColor: 'white' }}>
      <View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', height: 100 }}>
        <Text style={{ backgroundColor: '', padding: 20 }}>{'<'}</Text>
        <Text style={{ backgroundColor: '',}}></Text>
        <Text style={{ backgroundColor: '',}}></Text>
      </View>
      <Image source={require('../assets/images/splash-icon.png')}
        style={{ width: 200, height: 200, alignSelf: 'center', marginBottom: 50 }}
        resizeMode='stretch'
      ></Image>
      <Input placeholder='请输入邮箱' value={user} onChangeText={(e) => setUser(e)} />
      {user.length < 17 && user.length > 0 ? <Text>账号格式不正确</Text> : null}
      <View>
        <Text>
          还没有账号？<Link href="/login" style={{color:'blue'}}>注册</Link>
        </Text>
      </View>
      <Button title='登录' onPress={() => { login() }}></Button>
    </View>
  )
};